package com.zhilianbao.leyaogo.view.widgets;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bql.variousbanner.widget.banner.BaseIndicatorBanner;
import com.bql.variousbanner.widget.loopviewpager.ViewPagerCompat;
import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.utils.ImageUtils;
import com.zhilianbao.leyaogo.utils.Utils;

/**
 * 商品信息页面顶部的轮播图
 * Created by gyt on 2016/11/16
 */
public class DetailsTopBanner extends BaseIndicatorBanner<String, DetailsTopBanner> {
    private boolean showVideo;

    public DetailsTopBanner(Context context) {
        super(context);
    }

    public DetailsTopBanner(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DetailsTopBanner(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public View onCreateItemView(int position) {
        View contentView = null;
        contentView = View.inflate(context, R.layout.details_img_top_banner, null);
        ImageView mIvDetailsBanner = (ImageView) contentView.findViewById(R.id.iv_details_banner);
        ImageUtils.loadDetailPic(Utils.returnUrlShow(list.get(position)), mIvDetailsBanner);
        return contentView;
    }

    public LinearLayout getIndicatorContainer() {
        return ll_indicator_container;
    }


    /**
     * 拿到banner中第position位置的ImageView的drawable
     *
     * @return
     */
    public Drawable getDrawable(int position) {
        ViewPagerCompat viewPager = getViewPager();
        View child = viewPager.getChildAt(position);
        ImageView imageView = (ImageView) child.findViewById(R.id.iv_details_banner);
        return imageView.getDrawable();
    }

}
